home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #2 / Monster Media No. 2 (Monster Media)(1994).ISO / prog_c / tpchal_1.zip / TP.C < prev    next >
C/C++ Source or Header  |  1994-05-26  |  2KB  |  62 lines

  1. /*
  2. **  Tony Postmayer (1:267/113.26)
  3. */
  4.  
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7.  
  8. unsigned int  odd[][4] = {
  9.       {1,3,7,9},  {1,3,9,7},  {1,7,9,3},  {1,7,3,9},
  10.       {1,9,3,7},  {1,9,7,3},  {3,7,9,1},  {3,7,1,9},
  11.       {3,9,1,7},  {3,9,7,1},  {3,1,7,9},  {3,1,9,7},
  12.       {7,9,1,3},  {7,9,3,1},  {7,1,3,9},  {7,1,9,3},
  13.       {7,3,9,1},  {7,3,1,9},  {9,1,3,7},  {9,1,7,3},
  14.       {9,3,7,1},  {9,3,1,7},  {9,7,1,3},  {9,7,3,1}
  15. };
  16.  
  17. unsigned int even[][4] = {
  18.       {2,6,8,4},  {2,6,4,8},  {4,6,8,2},  {4,6,2,8},
  19.       {4,2,6,8},  {4,2,8,6},  {6,2,4,8},  {6,2,8,4},
  20.       {8,2,4,6},  {8,2,6,4},  {8,6,2,4},  {8,6,4,2}
  21. };
  22.  
  23. int main(void)
  24. {
  25.       unsigned int i, j;
  26.       unsigned long a, b, c, d, e, f, g, h, n;
  27. #ifdef TEST
  28.       int I;
  29.  
  30.       for (I = 0; I < 1000; ++I)
  31.       {
  32. #endif
  33.             for(i=0; i<24; i++)
  34.             {
  35.                   for(j=0; j<12; j++)
  36.                   {
  37.                         a = odd[i][0];
  38.                         b = 10 * a + even[j][0];
  39.                         c = 10 * b + odd[i][1];
  40.                         if (c%3)
  41.                               continue;
  42.                         d = 10 * c + even[j][1];
  43.                         e = 10 * d + 5;
  44.                         f = 10 * e + even[j][2];
  45.                         if (f%6)
  46.                               continue;
  47.                         g = 10 * f + odd[i][2];
  48.                         if (g%7)
  49.                               continue;
  50.                         h = 10 * g + even[j][3];
  51.                         if (h%8)
  52.                               continue;
  53.                         n = 10 * h + odd[i][3];
  54.                   }
  55.             }
  56. #ifdef TEST
  57.       }
  58. #endif
  59.       printf("%lu\n",n);
  60.       return(0);
  61. }
  62.